package com.rongshu.view.userInfo.presenter;

import android.content.Context;

import com.rongshu.api.RetorfitService;
import com.rongshu.view.base.mvp.BasePresenter;
import com.rongshu.view.base.mvp.INetBean;
import com.rongshu.view.userInfo.entity.EnshrineInfo;
import com.rongshu.view.userInfo.iview.EnshrineArticleView;

import rx.Subscriber;

public class EnshrineArticlePresenter extends BasePresenter<EnshrineArticleView> {

    public EnshrineArticlePresenter(Context context) {
        super(context);
    }

    /**
     * 我的收藏
     */
    public void getMyCollect(int user_id, int type, int pageIndex, int pageSize, String sign) {
        RetorfitService.getMyCollect(user_id, type, pageIndex, pageSize, sign)
                .subscribe(new Subscriber<EnshrineInfo>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(EnshrineInfo enshrineInfo) {
                        if (getView() != null) {
                            getView().onMyCollect(enshrineInfo);
                        }
                    }
                });
    }

    /**
     * 点击收藏/点击取消
     */
    public void getIsCollect(int user_id, int type, int content_id, String sign) {
        RetorfitService.getIsCollect(user_id, type, content_id, sign)
                .subscribe(new Subscriber<INetBean>() {
                    @Override
                    public void onCompleted() {

                    }

                    @Override
                    public void onError(Throwable e) {

                    }

                    @Override
                    public void onNext(INetBean iNetBean) {
                        if (getView() != null) {
                            getView().onIsCollect(iNetBean);
                        }
                    }
                });
    }
}
